<?php

import('@.Org.');

/**
 * 供货商列表信息
 *
 * @param       string      $conditions
 * @return      array
 */
function suppliers_list_info($conditions = ''){
    $where 			= 	'';
    if (!empty($conditions)){
        $where 		.= 	'WHERE ';
        $where 		.= 	$conditions;
    }
    /* 查询 */
    $sql 			= 	"SELECT suppliers_id, suppliers_name, suppliers_desc
			            FROM " . " ybr_suppliers " . "
			            $where";
    return M()->query($sql);
}

/**
 * 设置管理员的session内容
 *
 * @access  public
 * @param   integer $user_id        管理员编号
 * @param   string  $username       管理员姓名
 * @param   string  $action_list    权限列表
 * @param   string  $last_time      最后登录时间
 * @return  void
 */
function set_admin_session($user_id, $username, $action_list, $last_time){
    $_SESSION['admin_id']    	= 	$user_id;
    $_SESSION['admin_name']  	= 	$username;
    $_SESSION['action_list'] 	= 	$action_list;
    $_SESSION['last_check']  	= 	$last_time; // 用于保存最后一次检查订单的时间
}

/**
 * 获取管理员列表 
 * @return 	void
 * 
 */
function get_admin_userlist(){
    $list 			= 	array();
    $sql 			= 	'SELECT user_id, user_name, email, add_time, last_login '.
    			        ' FROM ' . ' ybr_admin_user ' . ' ORDER BY user_id DESC';
    $list 			= 	M()->query($sql);

    foreach ($list AS $key=>$val){
        $list[$key]['add_time']     	= 	local_date($GLOBALS['_CFG']['time_format'], $val['add_time']);
        $list[$key]['last_login']   	= 	local_date($GLOBALS['_CFG']['time_format'], $val['last_login']);
    }
    return $list;
}